package com.open.capacity.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.open.capacity.common.model.SttRole;
import com.open.capacity.common.model.SysRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
* @author 作者 owen 
* @version 创建时间：2017年11月12日 上午22:57:51
 * 角色
 */
@Component
public interface SysRoleDao extends BaseMapper<SttRole>{

	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into stt_role(rocode, roname) values(#{code}, #{name})")
	int save(SttRole sysRole);

	
	@Delete("delete from stt_role where roleid = #{id}")
	int deleteByPrimaryKey(Long id);
	
	@Update("update stt_role t set t.roname = #{name}  where t.roleid = #{id}")
	int updateByPrimaryKey(SttRole sysRole);

	@Select("select roleid id ,rocode code, roname name ,crtime createTime, uptime updateTime   from stt_role t where t.roleid = #{id}")
	SttRole findById(Long id);

	@Select("select roleid id ,rocode code, roname name ,crtime createTime, uptime updateTime , uptime from sys_role t where t.rocode = #{code}")
	SttRole findByCode(String code);

	int count(Map<String, Object> params);

	List<SttRole> findList(Map<String, Object> params);

}
